package com.phospherus.common.controller.handler;

import org.springframework.data.domain.Page;

/**
 * @author songjinlong
 * @version 1.0
 * @since 2017/04/18
 */
public class PageData<T> extends Data {
    private int pageSize;
    private int currPage;
    private long totalSize;
    private int totalPage;
    private boolean lastPage;
    private boolean firstPage;
    private long recordsTotal;
    private  long recordsFiltered;

    public PageData() {
    }

    public PageData(Page<T> page) {
        super(page.getContent());
        this.pageSize = page.getSize();
        this.currPage = page.getNumber();
        this.totalSize = page.getTotalElements();
        this.totalPage = page.getTotalPages();
        this.lastPage = page.isLast();
        this.firstPage = page.isFirst();
        this.recordsTotal = page.getTotalElements();
        this.recordsFiltered = page.getTotalElements();

    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public int getCurrPage() {
        return currPage;
    }

    public void setCurrPage(int currPage) {
        this.currPage = currPage;
    }

    public long getTotalSize() {
        return totalSize;
    }

    public void setTotalSize(long totalSize) {
        this.totalSize = totalSize;
    }

    public int getTotalPage() {
        return totalPage;
    }

    public void setTotalPage(int totalPage) {
        this.totalPage = totalPage;
    }

    public boolean isLastPage() {
        return lastPage;
    }

    public void setLastPage(boolean lastPage) {
        this.lastPage = lastPage;
    }

    public boolean isFirstPage() {
        return firstPage;
    }

    public void setFirstPage(boolean firstPage) {
        this.firstPage = firstPage;
    }

    public long getRecordsTotal() {
        return recordsTotal;
    }

    public void setRecordsTotal(long recordsTotal) {
        this.recordsTotal = recordsTotal;
    }

    public long getRecordsFiltered() {
        return recordsFiltered;
    }

    public void setRecordsFiltered(long recordsFiltered) {
        this.recordsFiltered = recordsFiltered;
    }
}
